<template>
	<view class="order-btn clearfix">
		<view class="btn fr" :class="item == '去支付' ? '' : item == '预支付' ? '' : item == '联系TA' ? '' : item == '确认完成' ? '' : 'cancel'" v-for="item in orderBtn" @click="operation(item)">
			{{ item }}
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {};
	},
	props: {
		orderBtn: '',
		orderId: '',
		businessId: '',
	},
	created() {
		var _this = this;
		// _this.orderBtn = _this.orderBtn
	},
	methods: {
		operation(item) {
			console.log(item,"item")
			var _this = this;
			if (item == '去支付') {
				_this.$Router.push({
					path: '/pageageA/pages/order/modifys',
					query: {
						uid: _this.orderId
					}
				});
			}
			if (item == '取消订单') {
				// _this.$Router.push({
				// 	path: '/pages/order/cancel',
				// 	query: {
				// 		orderId: _this.orderId
				// 	}
				// });
				uni.showModal({
				    title: '',
				    content: '确定要取消该订单吗？',
					cancelColor: '#57BFFF',
					confirmColor: '#57BFFF',
				    success: function (res) {
				        if (res.confirm) {
							_this.$http
							.get('/user/order/cancelOrder/' + _this.orderId)
							.then(function(response) {
								if (response.success) {
									uni.showToast({
										icon: 'none',
										position: 'bottom',
										title: '订单取消成功'
									})
									uni.navigateTo({
										url:'/pages/order/index'
									})
								} else {
									uni.showToast({
										icon: 'none',
										position: 'bottom',
										title: response.msg
									})
								}
							})
							.catch(function(error) {
								console.log(error);
							});
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
			if (item == '预支付') {
				_this.$Router.push({
					path: '/pageageA/pages/order/modify',
					query: {
						uid: _this.orderId
					}
				});
			}
			
			if (item == '去评价') {
				_this.$Router.push({
					path: '/pageageA/pages/order/evaluate',
					query: {
						orderId: _this.orderId,
						businessId: _this.businessId
					}
				});
			}
			if (item == '问题反馈') {
				_this.$Router.push({
					path: '/pageageA/pages/order/feed',
					query: {
						orderId: _this.orderId
					}
				});
			}
		}
	}
};
</script>

<style scoped lang="scss">
.btn {
	font-size: 26rpx;
	width: 170rpx;
	border-radius: 30rpx;
	text-align: center;
	line-height: 56rpx;
	height: 56rpx;
	color: $uni-color1;
	border: 2rpx solid $uni-color1;
	margin-left: 10rpx;
}
.cancel {
	color: #999;
	border: 2rpx solid #999;
	margin-left: 16rpx;
}
</style>
